<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <!-- 准备好容器 -->
  <div id="test"></div>

  <!--引入react核心库-->
  <script src="../react.js-16/react.development.js" type="text/javascript"></script>
  <!--引入react-dom，用于支持react操作DOM-->
  <script src="../react.js-16/react-dom.development.js" type="text/javascript"></script>
  <!--引入label，用于将jsx转为js-->
  <script src="../react.js-16/babel.min.js" type="text/javascript"></script>
  <!--引入prop-types，用于对组件标签属性的限制-->
  <script src="../react.js-16/prop-types.js" type="text/javascript"></script>

  <script type="text/babel">
    //1.创建组件>
    class Demo extends React.Component {
      state = { isHot: true }

      showInfo = () => {
        const { input } = this
        alert(input.value)
      }

      changeWether = () => {
        const { isHot } = this.state
        this.setState({ isHot: !isHot })
      }

      saveInput = (c) => {
        this.input = c
      }

      render() {
        const { isHot } = this.state
        return (
          <div>
            <h2>今天天气{isHot ? '炎热' : '凉爽'}</h2>
            {/*<input ref={c => { this.input = c }} type="text" /><br /><br />*/}
            <input ref={this.saveInput} type="text" /><br /><br />
            <button onClick={this.showInfo}>点我提示数据</button>
            <button onClick={this.changeWether}>点我切换天气</button>
          </div>
        )
      }
    }
    //2.渲染组件到页面
    ReactDOM.render(<Demo />, document.getElementById('test'))
  </script>
</body>

</html>